package com.atguigu.map;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: IDEAcode
 * @description:
 * @author: Mr.zjx
 * create: 2021-08-03-15-23
 **/
public class mapTest {
    public static void main(String[] args) {
        mapList();
    }
    private static void mapList(){
        Map<String,Integer> map = new HashMap<String,Integer>();
        map.put("a",97);
        map.put("b",98);
        map.put("c",99);
        map.put("d",100);
        Collection<Integer> values = map.values();//values():取出所有值
        for (Integer i : values)
            System.out.println(i);

        //存储重复建返回被覆盖之前的值
        Integer i = map.put("c",99);

        //Map集合的方法键获取值
        Integer b = map.get("b");

        //判断集合是否包含此键
        boolean k = map.containsKey("a");

        //判断集合是否包含此值
        boolean v = map.containsValue(99);

        //移除键返回值
        Integer b1 = map.remove("b");

        System.out.println("移除键返回值=" + b1);
        System.out.println("v = " + v);
        System.out.println("k = " + k);
        System.out.println("b = " + b);
        System.out.println("map = " + map);
        System.out.println("i = " + i);
    }
}
